package com.xh.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xh.entiy.User;
import com.xh.repository.UserRepository;

@Component
public class UserService {
	
	@Autowired
	private UserRepository userRepository;
	
	public void SaveOrUpdateUser(User user){
		userRepository.save(user);
	}
	
	public List<User> getUsers()
	{
		return (List<User>) userRepository.findAll();
	}
	
	public User getUser(Integer id)
	{
		return userRepository.findOne(id);
	}
	
	public void deleteUser(Integer id)
	{
		userRepository.delete(id);
	}
}
